﻿@model mesoBoard.Framework.Models.ThreadViewModel
@{
    Layout = "~/Views/Shared/_Posting.cshtml";
    string action = Model.EditorType == EditorType.Edit ? "Edit" : "Create";
}

@section BreadCrumbContent {
     @Html.Partial("_BoardBreadCrumb", Model.Forum)  &raquo;  @action Thread
}

<div class="posting create_thread section">
    
    <h2>
        @action Thread
    </h2>

    @if (Model.Preview.HasValue)
    { 
        <table class="post_preview">
            <tr>
                <th>Thread Preview</th>
            </tr>

            <tr>
                <td class="title">
                    Title: @Model.PreviewTitle
                </td>
            </tr>

            <tr>
                <td class="text">
                    @Html.Raw(Model.PreviewText)
                </td>
            </tr>
        </table>
    } 

    <form action="@Url.Action("ThreadValidate", "Post")" method="post" enctype="multipart/form-data">
        <dl>
            @Html.Partial("_ThreadEditor")

            @Html.Partial("_PostEditor")

            @if (Model.CanUploadAttachments)
            {
                @Html.Partial("_AttachmentsEditor")
            }

            @Html.Partial("_PollEditor")

            <dt>Options</dt>

            <dd>
                @Html.CheckBoxFor(model => model.PostEditor.SubscribeToThread)
                @Html.LabelFor(model => model.PostEditor.SubscribeToThread)
                <br />
                @Html.CheckBoxFor(model => model.PostEditor.ShowSignature)
                @Html.LabelFor(model => model.PostEditor.ShowSignature)
            </dd>

            <dt></dt>

            <dd>
                @Html.HiddenFor(model => model.ForumID) 
                <input type="submit" value="@action Thread"/>
                <button type="submit" name="Preview" value="true">Preview Thread</button>
                @Html.AntiForgeryToken() 
                @Html.ValidationMessage("TimeBetweenPosts") 
            </dd>

        </dl>
    </form>
</div>